<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.LinkedHashMap" %><%--
  Created by IntelliJ IDEA.
  User: HKemmm
  Date: 2021/3/29
  Time: 15:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>foreack练习</title>
</head>
<body>
此页面foeach练习<br>
<%
    List<Map<String,Object>> list = new ArrayList<>();
    Map<String,Object> map = new LinkedHashMap<>();
    map.put("stuName","张三");
    map.put("stuSex","男");
    map.put("stuScore",155);
    list.add(map);

    Map<String,Object> map1 = new LinkedHashMap<>();
    map1.put("stuName","小红");
    map1.put("stuSex","女");
    map1.put("stuScore",125);
    list.add(map1);

    Map<String,Object> map2 = new LinkedHashMap<>();
    map2.put("stuName","小明");
    map2.put("stuSex","男");
    map2.put("stuScore",135);
    list.add(map2);

    request.setAttribute("stuClass",list);
%>
<%--
相当于java中foreach循环，
item为遍历集合，用el表达式取出
var为每次一遍历的具体值
st为当前序号（从0开始）
--%>
<%--外层循环list中取出map--%>
<c:forEach items="${requestScope.stuClass}" var="eachValue" varStatus="st">
    ${st.index+1}
    <%--内层循环map中取出具体值--%>
    <c:forEach items="${eachValue}" var="eachMap">
        &nbsp;&nbsp;&nbsp;&nbsp;${eachMap.value}
    </c:forEach>
    <br>
</c:forEach>
</body>
</html>
